<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
            Add a Member to Website
            <small class="label label-warning">You can add a member and permitsion for whom</small>
          </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0)"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">request</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-body">
                    <form action="<?php echo base_url('admin/users/add');?>" id="frm_User_New"  method="post" onsubmit="return false;">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="col-md-12">
                                    <div class="form-group  <?php if(form_error('user_name') != NULL){echo 'has-error';}else if(!empty($error_user)){echo 'has-error';}?>">
                                        <label for="exampleInputName2">UserName</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="ion ion-person text-aqua"></i></span>
                                            <input type="text" class="form-control" id="exampleInputName2" placeholder="Enter Username" name="user_name" value = "<?php echo set_value('user_name');?>">
                                        </div>
                                        <?php echo form_error('user_name','<p class="help-block">','</p>');?>
                                        <?php if(!empty($error_user)){echo '<p class="help-block">'.$error_user.'</p>';}?>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group  <?php if(form_error('user_password') != NULL){echo 'has-error';}?>">
                                        <label for="exampleInputPassword1">Password</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-lock text-yellow"></i></span>
                                            <input type="password" class="form-control" id="exampleInputPassword1" name="user_password" value="<?php echo set_value('user_password');?>" placeholder="Password">
                                        </div>
                                        <?php echo form_error('user_password','<p class="help-block">','</p>');?>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group  <?php if(form_error('user_repass') != NULL){echo 'has-error';}?>">
                                        <label for="exampleInputPassword1">Re-Password</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-lock text-yellow"></i></span>
                                            <input type="password" class="form-control" name="user_repass" id="exampleInputPassword1" value="<?php echo set_value('user_repass');?>" placeholder="Password">
                                        </div>
                                        <?php echo form_error('user_repass','<p class="help-block">','</p>');?>
                                        <?php if(!empty($error_re)){echo '<p class="help-block">'.$error_re.'</p>';}?>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group  <?php if(form_error('user_fullname') != NULL){echo 'has-error';}?>">
                                        <label for="exampleInputName2 ">Full Name:</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="ion ion-person text-aqua"></i></span>
                                            <input type="text" class="form-control" id="exampleInputName2" name="user_fullname"  placeholder=" fisrt name">
                                        </div>
                                        <?php echo form_error('user_fullname','<p class="help-block">','</p>');?>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group  <?php if(form_error('user_email') != NULL){echo 'has-error';}else if(!empty($error_mail)){echo 'has-error';}?>">
                                        <label for="exampleInputName2">Email:</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-envelope text-aqua"></i></span>
                                            <input type="text" name="user_email" class="form-control" id="exampleInputName2" placeholder="Enter email">
                                        </div>
                                        <?php echo form_error('user_email','<p class="help-block">','</p>');?>
                                        <?php if(!empty($error_mail)){echo '<p class="help-block">'.$error_mail.'</p>';}?>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="exampleInputName2">Group: </label>
                                        <select class="form-control" name="role">
                                            <?php if(!empty($role)){?>
                                                <?php foreach($role as $value):?>
                                                    <option value="<?php echo $value['role_id'];?>" <?php if($value['role_id'] == 5){ echo 'selected = ""';} ?>><?php echo $value['role_name']?></option>
                                                <?php endforeach;?>
                                           <?php } ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group <?php if(form_error('avarta') != NULL){echo 'has-error';}else if(!empty($error_user)){echo 'has-error';}?>">
                                        <label for="exampleInputName2">Avarta: </label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-picture"></i></span>
                                            <input type="text" class="form-control" id="exampleInputName2" name="avarta" value="<?php echo set_value('avarta');?>" placeholder="Your link avata">
                                        </div>
                                        <?php echo form_error('avarta','<p class="help-block">','</p>');?>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group <?php if(form_error('facebook') != NULL){echo 'has-error';}else if(!empty($error_user)){echo 'has-error';}?>">
                                        <label for="exampleInputName2">Facebook: </label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-globe text-light-blue"></i></span>
                                            <input type="text" class="form-control" id="exampleInputName2" name="facebook" value="<?php echo set_value('facebook');?>" placeholder="Your link facebook">
                                        </div>
                                        <?php echo form_error('facebook','<p class="help-block">','</p>');?>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="exampleInputName2" style="margin-right: 10px;">Active:</label>
                                        <input tabindex="5" type="checkbox" checked="" id="minimal-checkbox-1 col-md-2" name="active">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="box-footer clearfix">
                                    <button type="submit" onclick="New()" class="btn btn-success pull-right">Submit</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- /.box-body -->
        </div>
    </div>
</section>
<script>
    $('input[type="checkbox"]').iCheck({
      checkboxClass: 'icheckbox_flat-blue',
      radioClass: 'iradio_flat-blue'
    });

    function New(){
        $.post($('#frm_User_New').attr('action'),$('#frm_User_New').serialize(),function(result){
            console.log(result.content);
            if(result.error == 1){
                $.notification({type:"error",img:"",width:"400",content:"<i class='fa fa-times-circle fa-2x'></i> <?php echo 'There is an error, please check again!'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                $('.content-wrapper').html(result.content);
                $('input[type="checkbox"]').iCheck({
                  checkboxClass: 'icheckbox_flat-blue',
                  radioClass: 'iradio_flat-blue'
                });
            }else{
                $.notification({type:"success",img:"",width:"400",content:"<i class='fa fa-check fa-2x'></i> <?php echo 'successful account registration!'; ?>",html:true,autoClose:true,timeOut:"1500",delay:"0",position:"topRight",effect:"fade",animate:"fadeUp",easing:"jswing",onStart:function(id){ console.log(' onStart : notification id = '+id); },onShow:function(id){ console.log(' onShow : notification id = '+id); },onClose:function(id){ console.log(' onClose : notification id = '+id); },duration:"300"});
                $('.content-wrapper').load(result.url,function(){
                    $('input[type="checkbox"]').iCheck({
                      checkboxClass: 'icheckbox_flat-blue',
                      radioClass: 'iradio_flat-blue'
                    });
                });
            }
        },'json');
    }

    function back_to_list(){
        $(".content-wrapper").mask("<?php echo 'Loading...'; ?>");
        $(".content-wrapper").load('<?php echo base_url("admin/users/list_all");?>',function(){
        });
    }
</script>